package databases

import (
	"github.com/go-xorm/xorm"
	"github.com/juju/errgo/errors"
	"gitlab.gaodun.com/golib/gderror"
	"permission/config"
	"permission/vigo_loger"
)

type NavigationFunFactory struct {
	Table        Tpo_Sys_Navigation_Function
	engine       *xorm.Engine
	RowsSlicePtr []Tpo_Sys_Navigation_Function
}

// 返回 user factory
func NewNavigationFunFactory() *NavigationFunFactory {
	funcFac := NavigationFunFactory{}
	funcFac.engine, _ = config.InitEng()
	return &funcFac
}

func (nff *NavigationFunFactory) FindInfoByFuncIds(funcIds ...int64) error {
	if len(funcIds) == 0 {
		return errors.New("func Id is null")
	}

	err := nff.engine.In("FunctionId", funcIds).Find(&(nff.RowsSlicePtr))
	if err != nil {
		vigo_loger.AddGrayLog(gderror.New(err.Error()).Error())
	}
	return err
}
